﻿using Safe_Driving.TokenUser;

using System.Windows.Media;
using System.IO.Packaging;
using System.IO;
//using System.Windows.Xps.Packaging;
//using System.Windows.Xps;
//using pdftron.PDF;

namespace Safe_Driving
{
    public partial class MainWindow
    {
        /*
        public void EditFacture()
        {
            SingletonTokenUser token = SingletonTokenUser.GetInstance();
            SFClient client = token.Client_selected;

            string pOut = @"D:\Test\Onche.xps";

            // STEP 1: Create or get a WPF Visual
            DrawingVisual visual = new DrawingVisual();
            {
                DrawingContext dc = visual.RenderOpen();
                Pen bluePen = new Pen(Brushes.Blue, 1);
                dc.DrawRectangle(Brushes.Yellow, bluePen, new System.Windows.Rect(10, 10, 800, 1000));
                Brush pinkBrush = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255));
                Pen blackPen = new Pen(Brushes.Black, 1);
                dc.DrawEllipse(pinkBrush, blackPen, new System.Windows.Point(400, 500), 300, 200);
                dc.Close();
            }

            // STEP 2: Convert this WPF Visual to an XPS Document
            MemoryStream lMemoryStream = new MemoryStream();
            {
                Package package = Package.Open(lMemoryStream, FileMode.Create);
                XpsDocument doc = new XpsDocument(package);
                XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);
                writer.Write(visual);
                doc.Close();
                package.Close();
            }

            // STEP 3: Convert this XPS Document to a PDF file
            MemoryStream lOutStream = new MemoryStream();

            PDFDoc pdfdoc = new PDFDoc();
            pdftron.PDF.Convert.FromXps(pdfdoc, pOut);
            //NiXPS.Converter.XpsToPdf(lMemoryStream, lOutStream);
            File.WriteAllBytes(pOut, lMemoryStream.ToArray() /*lOutStream.ToArray()*/ /*);
            


        }
        */
        
    }
}
